package com.jackrain.nea.fc.cp.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.jdbc.SQL;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 店仓属性mapper层
 *
 * @author wuwenxue
 * @date 2018/01/19
 **/
@Mapper
public interface ViewCstoredimMapper {

    class ViewCstoreDimSql {
        public String findCstoredim(Map<String, Object> map) {
            Object[] id = (Object[]) map.get("idArray");
            return new SQL() {
                {
                    SELECT("a.AD_STORECOLUMN_NAME,a.FLAGNAME,b.ECODE,b.ENAME,b.REMARK,b.ORDERNO,b.ISACTIVE," +
                            "b.MODIFIEDDATE,b.MODIFIERNAME");
                    FROM("CP_C_STOREDIM a,cp_c_storedim_item b");
                    StringBuffer sb = new StringBuffer();
                    for (int i = 0; i < id.length; i++) {
                        sb.append(id[i] + ",");
                    }
                    sb.deleteCharAt(sb.length() - 1);
                    WHERE("b.id IN (" + sb.toString() + ")");
                    WHERE("a.id=b.CP_C_STOREDIM_ID");
                }
            }.toString();
        }
    }

    /**
     * 根据传入ids查询店仓属性及对应的店仓属性值
     *
     * @param idArray 传入IDS数组
     * @return List
     */
    @SelectProvider(type = ViewCstoreDimSql.class, method = "findCstoredim")
    List<HashMap> findAllStoredim(@Param("idArray") Object[] idArray);





}
